import static org.junit.Assert.*;

import java.awt.Color;

import etc.Mule;
import game.Game;
import game.GameDriver;
import game.Round;

import org.junit.Before;
import org.junit.Test;

import panels.MapPanel;
import player.Alien;
import player.Flapper;
import player.Human;
import player.Player;
import tiles.Tile;
import town.Store;

public class DhruvTest {
    GameDriver driver;
    Game game;
    Round round;

    Player p1;
    Player p2;
    Player p3;
    Player p4;

    Store store;

    @Before
    public void setUp() {
	driver = new GameDriver();
	game = new Game(4, 1, 1);

	p1 = new Player(game, "bob", Color.RED, "red", new Flapper());
	p2 = new Player(game, "sally", Color.CYAN, "cyan", new Human());
	p3 = new Player(game, "dave", Color.GREEN, "green", new Human());
	p4 = new Player(game, "phil", Color.YELLOW, "yellow", new Alien());

	game.setPlayer(p1, 0);
	game.setPlayer(p2, 1);
	game.setPlayer(p3, 2);
	game.setPlayer(p4, 3);

	round = new Round(game, driver);
	store = new Store(game, driver, round);

    }

    @Test
    public void testProduction() {
	MapPanel map = new MapPanel(game, driver, round);

	// buying and placing three different kinds of mules
	Tile tileToAdd = map.getMap()[2][2];
	p1.addProperty(tileToAdd);
	p1.buyMule(0);
	round.getCurrPlayer().placeMule(tileToAdd);

	Tile tileToAdd2 = map.getMap()[3][2];
	p1.addProperty(tileToAdd2);
	p1.buyMule(1);
	round.getCurrPlayer().placeMule(tileToAdd2);

	Tile tileToAdd3 = map.getMap()[4][1];
	p1.addProperty(tileToAdd3);
	p1.buyMule(2);
	round.getCurrPlayer().placeMule(tileToAdd3);

	// updating to go to next round
	round.incrementPlayerInt();
	round.getCurrPlayer().getProduction();
	round.incrementPlayerInt();
	round.getCurrPlayer().getProduction();
	round.incrementPlayerInt();
	round.getCurrPlayer().getProduction();
	round.incrementPlayerInt();
	round.getCurrPlayer().getProduction();

	// System.out.println(round.getCurrPlayerResourceBasket());
	assertEquals(p1.getResourceBasket().getResource(0), 10);
	assertEquals(p1.getResourceBasket().getResource(1), 7);
	assertEquals(p1.getResourceBasket().getResource(2), 1);
    }
}
